﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.UpgradesUI {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import Classes.*;
    import Classes.util.*;
    import com.greensock.*;

    public class MunicipalUpgradesDialog extends GenericDialog {

        protected var m_buildingName:String;
        protected var m_crewData:Array;
        protected var m_finishCheckCB:Function;
        protected var m_finishCB:Function;
        protected var m_buyAllHandler:Function;
        protected var m_targetObjectId:Number;

        public function MunicipalUpgradesDialog(_arg1:String, _arg2:Array, _arg3:Function, _arg4:Function, _arg5:Function, _arg6:Number){
            this.m_buildingName = _arg1;
            this.m_crewData = _arg2;
            this.m_finishCheckCB = _arg3;
            this.m_finishCB = _arg4;
            this.m_buyAllHandler = _arg5;
            this.m_targetObjectId = _arg6;
            super("", "", 0, null, "UpgradesUI", "", false);
        }
        override protected function createDialogView(_arg1:Dictionary):GenericDialogView{
            return (new MunicipalUpgradesDialogView(this.m_buildingName, this.m_crewData, this.m_finishCheckCB, this.m_finishCB, this.m_buyAllHandler, this.m_targetObjectId));
        }
        override protected function loadAssets():void{
            Global.delayedAssets.get(DelayedAssetLoader.UPGRADES_ASSETS, makeAssets);
        }
        override protected function createAssetDict():Dictionary{
            UpgradesCommonAssets.assetDict["dialogBG"] = (new m_comObject.upgrades_bg() as DisplayObject);
            UpgradesCommonAssets.assetDict["checkMark"] = m_comObject.upgrades_checkmark;
            UpgradesCommonAssets.assetDict["crewIcon"] = m_comObject.upgrades_crewIcon;
            UpgradesCommonAssets.assetDict["blankPortrait"] = m_comObject.upgrades_portrait_missing;
            UpgradesCommonAssets.assetDict["scrollBorder"] = m_comObject.upgrades_scrollBorder;
            UpgradesCommonAssets.assetDict["scrollCircle"] = m_comObject.upgrades_scrollCircle;
            UpgradesCommonAssets.assetDict["upgradeArrow"] = m_comObject.upgrades_upgradeArrow;
            UpgradesCommonAssets.assetDict["manilaCard"] = m_comObject.upgrades_manilaCard;
            UpgradesCommonAssets.assetDict["up_disabled"] = m_comObject.upgrades_up_disabled;
            UpgradesCommonAssets.assetDict["up_over"] = m_comObject.upgrades_up_over;
            UpgradesCommonAssets.assetDict["up_up"] = m_comObject.upgrades_up_up;
            UpgradesCommonAssets.assetDict["down_disabled"] = m_comObject.upgrades_down_disabled;
            UpgradesCommonAssets.assetDict["down_over"] = m_comObject.upgrades_down_over;
            UpgradesCommonAssets.assetDict["down_up"] = m_comObject.upgrades_down_up;
            return (UpgradesCommonAssets.assetDict);
        }
        public function activateFinishButton():void{
            (m_jpanel as MunicipalUpgradesDialogView).rebuildButtons();
        }
        override protected function showTween():void{
            this.mouseEnabled = (this.mouseChildren = false);
            this.centerPopup();
            m_content.alpha = 0;
            m_content.scaleX = (m_content.scaleY = 1);
            TweenLite.to(m_content, TWEEN_TIME, {
                alpha:1,
                onComplete:onShowComplete
            });
        }
        override public function centerPopup():void{
            var _local1:Rectangle;
            var _local2:Point;
            var _local3:Number;
            if (parent){
                _local1 = Global.hud.getRect(parent);
                _local2 = new Point(((Global.stage.stageWidth - m_jpanel.width) / 2), ((Global.stage.stageHeight - m_jpanel.height) / 2));
                _local3 = Global.hud.localToGlobal(new Point(Global.hud.x, Global.hud.y)).x;
                this.x = (_local2.x - _local3);
                this.y = _local2.y;
            };
        }
        override public function close():void{
            var _local1:MapResource = (Global.world.getObjectById(this.m_targetObjectId) as MapResource);
            _local1.setShowUpgradeArrow(false);
            _local1.setState(_local1.getState());
            dispatchEvent(new Event(Event.CLOSE));
            onHide();
        }

    }
}//package Display.UpgradesUI 
